require "Common/define"
require "Logic/Config"
require "Common/functions"
require "Common/EnumConst"
require "Battle/Entity/SpineEffect"

EntityShadow = {};
EntityShadow.__index = EntityShadow;

function EntityShadow:new()
    local object ={};
    object.skeletonAnimation = nil;

    setmetatable(object, EntityShadow);
    return object;
end


function EntityShadow:init(entity)

    local aniTrans =  entity.roleObj.transform:Find("shadow/Animation");
    self.skeletonAnimation = aniTrans.gameObject:GetComponent(TSkeletonAnimation);
    Util.SetOrder(aniTrans.gameObject, Config.SortingDefault.Shadow);
	entity.shadow.skeletonAnimation.Skeleton.A = 1;
    entity.shadowObj = self;
end

function EntityShadow:playAnimation(aniName, loop, time, isEffect, timeScale)
    --SpineEffect
    if aniName == "skill1_2" then
        local a = 1;
    end
    if self.skeletonAnimation then
        Util.PlayAction(self.skeletonAnimation, aniName, loop, time, isEffect, timeScale);
    end
end

function EntityShadow:setFlip(flip)
    if self.skeletonAnimation then
        Util.SetFlipX(self.skeletonAnimation, flip);
    end
end


function EntityShadow:destroy()
    if self.skeletonAnimation ~= nil then
        self.skeletonAnimation = nil;
    end
end




